<template>
<div id="train">
  <div id="trainIndex">
    <el-breadcrumb separator=">">
      <el-breadcrumb-item :to="{ path: '/' }">系统首页</el-breadcrumb-item>
      <el-breadcrumb-item :to="{ path: '/train' }">干部培训</el-breadcrumb-item>
      <el-breadcrumb-item>全部人员</el-breadcrumb-item>
    </el-breadcrumb>
    <filed-candidate @changeHeight="tableresize()" ref="filedCandidate" type="filed" :canEdit="canEdit" :tableHeight="tableHeight" />
  </div>
</div>
</template>

<script>
import filedCandidate from './filedCandidate.vue'
export default {
  components: { filedCandidate },
  data () {
    return {
      canEdit: false,
      viewtype: 1,
      filters: {},
      btnLoading: false,
      tableHeight: 100,
      maxId: 0,
      isAdmin: true, // 临时调整为true
      isChuzhang: false,
      shhlist: [],
      shhlist2: [
      ],
      listLoading: false,
      totalnum: 0,
      addFormVisible: false, // 新增界面是否显示
      addLoading: false,
      // 新增界面数据
      addForm: {
        Name: '',
        TheYear: ''
      },
      addFormRules: {
        Name: [
          { required: true, message: '必填项', trigger: 'blur' }
        ],
        TheYear: [
          { required: true, message: '必填项', trigger: 'blur' }
        ]
      },
      editFormRules: {
        Name: [
          { required: true, message: '必填项', trigger: 'blur' }
        ],
        TheYear: [
          { required: true, message: '必填项', trigger: 'blur' }
        ]
      },
      editFormVisible: false, // 编辑界面是否显示
      editLoading: false,
      // 编辑界面数据
      editForm: {
        Name: '',
        TheYear: '',
        Id: 0
      }
    }
  },
  methods: {
    inRoles (str) {
      let arr = JSON.parse(localStorage.getItem('Roles'))
      if (arr.indexOf(str) === -1) {
        return false
      } else {
        return true
      }
    },
    handleIndex () {
      this.$router.push({name: `Train`})
    },
    handleAuth () {
      this.$router.push({name: `trainAuth`})
    },
    handleChart () {
      this.$router.push({name: `trainChart`})
    },
    showperson (id) {
      this.mypersonid = id
      console.log('mypersonid:' + this.mypersonid)
      this.showpersonVisible = true
    },
    tableresize (obj) {
      obj = obj || this
      var clientHeight = 0
      if (document.body.clientHeight && document.documentElement.clientHeight) {
        clientHeight = (document.body.clientHeight < document.documentElement.clientHeight) ? document.body.clientHeight : document.documentElement.clientHeight
      } else {
        clientHeight = (document.body.clientHeight > document.documentElement.clientHeight) ? document.body.clientHeight : document.documentElement.clientHeight
      }
      let tableHeightFix = this.$refs['filedCandidate'].showMore ? '468' : '282'
      obj.$nextTick(function () {
        obj.tableHeight = clientHeight - tableHeightFix
      })
    },
    getCanEdit () {
      if (this.inRoles('ROLE_training')) {
        this.canEdit = true
      } else {
        this.canEdit = false
      }
    }
  },
  mounted () {
    this.getCanEdit() // 移入组建后未使用
    this.tableresize(this)
    let _this = this
    window.onresize = function windowResize () {
      // 通过捕获系统的onresize事件触发我们需要执行的事件
      _this.tableresize(_this)
    }
  }
}
</script>
<style>
  #trainIndex .wboxd .el-table th{
    font-weight: normal;
    background-image: linear-gradient(to bottom , #f8f8f8, #efefef);
  }
  #trainIndex .wboxd .el-table td,
  #trainIndex .el-table th{
    padding:0;
    font-size:var(--size14) !important;
    line-height: 20px;
    font-family: '宋体'
  }
  #trainIndex .el-table--border th,
  #trainIndex .el-table--border td {
    border-right: 1px solid #95B8E7;
  }
  #trainIndex .el-table th.is-leaf,
  #trainIndex .el-table td {
    border-bottom: 1px solid #95B8E7;
  }
  #trainIndex .el-table td{
    border-right: 1px solid #95B8E7;
    border-bottom: 1px solid #95B8E7;
  }

</style>
<style scoped>
  #trainIndex h1{
    font-size:var(--size16) !important;
    font-weight: bolder;
    height: 30px;
    border-bottom: 1px solid #95B8E7;
    font-family: '宋体';
    line-height: 30px;
    color: #000;
    padding-left:10px;
    background-image: linear-gradient(to bottom , #EEF4FF, #E0ECFF);
    margin:0;
  }
  #trainIndex .el-pagination{
    float: left;
    padding:7px 10px;
  }
  #trainIndex .wboxs{
    padding:5px 15px;
    width: calc(100% - 30px);
    background: #fff;
    border: 1px solid #95B8E7;
    margin:0 10px;
    overflow: hidden;
  }
  #trainIndex .wboxd{
    padding:0;
    width: calc(100% - 0px);
    background: #fff;
    border: 1px solid #95B8E7;
    margin:0 10px;
    overflow: hidden;
  }
  .el-table{
    border-top: 1px solid #95B8E7 !important;
  }
  .el-table--border th, .el-table--border td {
    border-right: 1px solid #95B8E7 !important;
  }
  .el-table th.is-leaf, .el-table td {
    border-bottom: 1px solid #95B8E7 !important;
    border-right: 1px solid #95B8E7 !important;
  }
</style>
